package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.AddReportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yixun.qfbao.apidto.CompletePhoneReqDto;
import com.yixun.qfbao.apidto.CompletePhoneResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.util.exception.TServerException;
import com.yixun.qfbao.vo.CompletePhoneReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;

/**
 * 补全号码
 * 
 * @author JHSong
 *		
 */
@Service("completePhoneHander")
public class CompletePhoneHander extends CommonAbstractHander {
	private static Logger logger= LoggerFactory.getLogger(CompletePhoneHander.class);

	@Autowired
	private AddReportService addReportService;
	
	@Override
	public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
		CompletePhoneReqVo req = (CompletePhoneReqVo)reqDto;
		CompletePhoneReqDto reqDto1 = req.getParams();
		BaseResponseDTO<CompletePhoneResDto> res = new BaseResponseDTO<CompletePhoneResDto>();
		CompletePhoneResDto resDto = new CompletePhoneResDto();
		try {
			resDto = addReportService.completePhone(reqDto1);
		} catch (TServerException e) {
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg(e.getErrorMsg());
		} catch (Exception e) {
			logger.error("CompletePhoneHander error: {}", e);
			resDto.setResult(ResultEnum.FAIL.getNo());
			resDto.setResultMsg("系统异常");
		}
		res.setResData(resDto);
		res.setResult(resDto.getResult());
		return res;
	}
	
}
